// Pressure sensor program - zahra almukhariq - fab academy 2019 #include #define RX 0 #define TX 1 SoftwareSerial mySerial(RX, TX); const int SensorPin = A0; // Analog input pin int sensorValue = 0; // value read from the sensor float outputValue = 0; // value output float pressurevalue = 0; // value of pressure void setup() { // initialize serial communications at 9600 bps: mySerial.begin(9600); mySerial.print("begin "); } void loop() { // read the analog in value: sensorValue = analogRead(SensorPin); // convert the reading to voltage: outputValue = sensorValue * (5 / 1023.0); // convert from voltage to pressre: pressurevalue = ((outputValue - 2.5) / 0.090); // output the results to the Serial Monitor: mySerial.print("voltage = "); mySerial.print(outputValue); mySerial.print("\t pressure value = "); mySerial.println(pressurevalue); // wait 2 milliseconds before the next loop for the analog-to-digital // converter to settle after the last reading: delay(2); }